﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefProductionInbound" :model="stateProductionInbound.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineId_FormItem" prop="Entity.LineId" :label="$t('message.autotrans._Model_ProductionInbound_LineId')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.LineId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineCode_FormItem" prop="Entity.LineCode" :label="$t('message.autotrans._Model_ProductionInbound_LineCode')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.LineCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpId_FormItem" prop="Entity.OpId" :label="$t('message.autotrans._Model_ProductionInbound_OpId')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.OpId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OpCode_FormItem" prop="Entity.OpCode" :label="$t('message.autotrans._Model_ProductionInbound_OpCode')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.OpCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_ProductionInbound_ProductId')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.ProductId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductCode_FormItem" prop="Entity.ProductCode" :label="$t('message.autotrans._Model_ProductionInbound_ProductCode')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.ProductCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Sn_FormItem" prop="Entity.Sn" :label="$t('message.autotrans._Model_ProductionInbound_Sn')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.Sn" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Wo_FormItem" prop="Entity.Wo" :label="$t('message.autotrans._Model_ProductionInbound_Wo')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.Wo" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Rfid_FormItem" prop="Entity.Rfid" :label="$t('message.autotrans._Model_ProductionInbound_Rfid')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.Rfid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InboundTime_FormItem" prop="Entity.InboundTime" :label="$t('message.autotrans._Model_ProductionInbound_InboundTime')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.InboundTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_InboundStatus_FormItem" prop="Entity.InboundStatus" :label="$t('message.autotrans._Model_ProductionInbound_InboundStatus')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.InboundStatus" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Ver_FormItem" prop="Entity.Ver" :label="$t('message.autotrans._Model_ProductionInbound_Ver')">
            <el-input v-model="stateProductionInbound.vmModel.Entity.Ver" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_ProductionInbound_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionInbound_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductionInbound.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseProductionInbound"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProductionInboundDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productioninboundApi } from '/@/api/productionmanagement/productioninbound';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProductionInbound = ref();
const stateProductionInbound = reactive({
    vmModel: {
	  Entity:{
        LineId: null,
        LineCode: '',
        OpId: null,
        OpCode: '',
        ProductId: null,
        ProductCode: '',
        Sn: '',
        Wo: '',
        Rfid: '',
        InboundTime: undefined,
        InboundStatus: null,
        Ver: null,
        IsValid: undefined,
        ID:null,
      },

	},
    
});

// 取消
const onCloseProductionInbound = () => {
    closeDialog();
};

// 提交
const onSubmitProductionInbound = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefProductionInbound.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            productioninboundApi().edit(stateProductionInbound.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProductionInbound.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProductionInbound.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	productioninboundApi().get(stateProductionInbound.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateProductionInbound.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

